<?php
###############   COPYLEFT GPLv3 LICENSE   ###############
##
## JFX Version 0.2.7
## Website Management Software
## www.jfxcms.com
##
## Copyright 2009 GPLv3 - http://www.opensource.org/licenses/gpl-3.0.html
##
## Anthony Gallon
## oi_antz@hotmail.com
##
## Permission is hereby granted to any person having a copy of this software
## to freely use and modify as required so long as the copyright notices
## and branding remain intact.
##
## Full license details available at http://www.jfxcms.com/license
##
###############   COPYLEFT GPLv3 LICENSE   ################

class VMS_FileCompare
{
    protected $leftData = array(
        'filename'=>'',
        'content'=>'',
        'data'=>'',
        'update_url'=>''
    );

    protected $rightData = array(
        'filename'=>'',
        'content'=>'',
        'data'=>'',
        'update_url'=>''
    );

    public function setLeft($data){
        foreach($this->leftData as $k=>$v){
            if(array_key_exists($k, $data)) $this->leftData[$k] = $data[$k];
        }
    }

    public function setRight($data){
        foreach($this->rightData as $k=>$v){
            if(array_key_exists($k, $data)) $this->rightData[$k] = $data[$k];
        }
    }

    public function prepare(){
        $leftLines = explode("\n", $this->leftData['content']);
        $rightLines = explode("\n", $this->rightData['content']);

        $identicalLines = array();
        $leftNewLines = array();
        $rightNewLines = array();
        $leftGoneLines = array();
        $rightGoneLines = array();

        foreach($leftLines as $k=>$v){
            
        }

    }


    public function lineOccursLater($value, $lineNumber, $lines){
        for($i=$lineNumber; $i<count($lines); $i++){
            if($lines[$i]==$value) return $i;
        }
        return false;
    }



    public function __toString(){

        $SMARTY = JFX::registry('Smarty');
        $SMARTY->assign('leftData', $this->leftData);
        $SMARTY->assign('rightData', $this->rightData);

        return JFX::fetchSmarty($this->template);

    }



    protected $template = '

<div class="vmsfc-container">
    <div class="vmsfc-left">
        <h2>{$leftData.filename}</h2>
        <div class="vmsfc-left-content">
            {$leftData.content}
        </div>
    </div>
    <div class="vmsfc-right">
        <h2>{$rightData.filename}</h2>
        <div class="vmsfc-right-content">
            {$rightData.content}
        </div>
    </div>
</div>

';


}